<template>
  <div v-if="type === 'cell'">
    <div v-if="readonly || !editable">
      <van-form>
        <van-field readonly>
          <template #label>
            <OLabel :data-info="dataInfo" :view-info="viewInfo" />
          </template>

          <template #input>
            <img
              class="img img-fluid"
              :src="image_url"
              alt="二进制文件"
              :style="img_style"
            />
          </template>
        </van-field>
      </van-form>
    </div>

    <div v-else>
      edit: img:{{ image_url }}
      <!-- <Upload :imageUrl="image_url" @on-change="onchange" /> -->
    </div>
  </div>

  <div v-else>todo: image</div>
</template>

<script>
import OWMixin from './OWMixin'
import api from '@/odooapi'

import OLabel from '../OLabel.vue'

// import Upload from './OInput/Upload.vue'

export default {
  name: 'WImage',
  components: { OLabel },
  mixins: [OWMixin],
  props: {},
  data() {
    return {}
  },
  computed: {
    img_style() {
      if (this.widget === 'many2one_avatar_user') return 'width: 30%'
      else {
        return 'width: 30%'
        // return undefined
      }
    },

    //

    image_url() {
      const record = this.record
      // console.log(api)
      // console.log('image_url,  ', this, this.editable)
      const url = api.Node.image_url(this.viewInfo, record)
      return url
    }
  },

  watch: {},

  created() {},

  mounted() {},

  methods: {}
}
</script>

<style type="text/css"></style>
